<template>
	<view class="uni-flex-column container">
		<view class="content">
			<view class="detail">
				<view class="uni-flex uni-justify-between uni-align-center top">
					<view class="uni-flex uni-align-center">
						<text class="text1">{{ detailData.title }}</text>
						<text class="text2">{{ detailData.orderTypeName }}</text>
					</view>
					<text class="text3">{{ detailData.orderStatusName }}</text>
				</view>
				<view class="uni-flex content">
					<image :src="detailData.orderServices?.[0]?.img" mode="aspectFill"></image>
					<view class="uni-flex-column info">
						<text class="title">{{ detailData.orderServices?.[0]?.name }}</text>
						<text class="des">{{ detailData.orderServices?.[0]?.desc }}</text>
						<text class="num">x {{ detailData.orderServices?.[0]?.count }}</text>
					</view>
					<text class="price">¥{{ detailData.orderServices?.[0]?.price }}</text>
				</view>

				<view class="uni-flex menu">
					<text class="button1">申请售后</text>
					<!-- <text class="button1">取消订单</text> -->
					<!-- <text class="button1">去评价</text> -->
					<!-- <text class="button2" @click="handlePay(item)">去付款</text> -->
					<text class="button2">再来一单</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { orderDetail } from "@/api/consumerOrder.js";

const selectedIndex = ref(-1);
// 点击评价
const evaluteClick = (index, item) => {
	selectedIndex.value = index;
};

const copyText = (id) => {
	uni.setClipboardData({
		data: id,
		success: function () {
			console.log("success");
		}
	});
};

const orderId = ref("");
const detailData = ref(null);
const getOrderDetail = () => {
	console.log(orderId, orderId.value);
	orderDetail(orderId.value).then((response) => {
		detailData.value = response.data;
		// Object.assign(detailData.value, response.data);
		console.log(detailData.value, "detailData.value");
	});
};

onMounted(() => {
	getOrderDetail();
	console.log(detailData.value, "detailData.value1");
});

onLoad((option) => {
	orderId.value = option.id;

	console.log(option, orderId.value, "option");
});
</script>

<style lang="scss" scoped>
.container {
	background: #f5f5f5;
	height: 100vh;
	box-sizing: border-box;
	padding-top: 24rpx;
	.content {
		flex: 1;
		overflow-y: auto; // 允许滚动
	}
	.detail {
		margin: 0 24rpx;
		padding: 31rpx 39rpx 25rpx 25rpx;
		background: #fff;
		border-radius: 20rpx;
		box-sizing: border-box;
		.top {
			.text1 {
				font-size: 34rpx;
				color: #333333;
				display: inline-block;
				max-width: 300rpx;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
			.text2 {
				font-weight: 400;
				font-size: 24rpx;
				color: #2f80ed;
				background: #e5f0ff;
				border-radius: 4px;
				padding: 2rpx 9rpx;
				margin-left: 14rpx;
			}
			.text3 {
				font-weight: 500;
				font-size: 34rpx;
				color: #999999;
			}
		}

		.content {
			margin-top: 30rpx;
			image {
				width: 137rpx;
				height: 137rpx;
			}

			.info {
				flex: 1;
				margin-left: 24rpx;
				.title {
					font-weight: 500;
					font-size: 34rpx;
					color: #333333;
					max-width: 300rpx;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
				}
				.des {
					font-weight: 400;
					font-size: 28rpx;
					color: #666666;
					margin-top: 5rpx;
					max-width: 350rpx;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
				}
				.num {
					font-size: 28rpx;
					color: #666666;
					margin-top: 12rpx;
				}
			}

			.price {
				font-weight: 500;
				font-size: 34rpx;
				color: #333333;
			}
		}

		.menu {
			justify-content: flex-end;
			margin-top: 24rpx;
			.button1 {
				font-size: 24rpx;
				color: #333333;
				padding: 12rpx 32rpx;
				border: 1px solid #999999;
				border-radius: 28rpx;
				margin-right: 24rpx;
			}
			.button2 {
				font-size: 24rpx;
				color: #ffffff;
				padding: 12rpx 32rpx;
				background: #2f80ed;
				border-radius: 28rpx;
			}
		}
		.money-box {
			margin-top: 24rpx;
			.text1 {
				font-size: 28rpx;
				color: #666666;
			}
			.money {
				font-size: 32rpx;
				color: #333333;
			}
			&:last-child {
				padding-bottom: 24rpx;
				border-bottom: 1rpx solid #e2e2e2;
			}
		}
		.info-item-box {
			margin-top: 24rpx;
			.text1 {
				font-size: 28rpx;
				color: #666666;
				flex-shrink: 0;
				margin-right: 36rpx;
			}
			.text2 {
				font-size: 28rpx;
				color: #999999;
				text-align: right;
			}
			.text3 {
				font-size: 28rpx;
				color: #333333;
				margin-left: 30rpx;
			}
		}
	}
}
</style>